cmake_minimum_required(VERSION 2.8)
project(jf_aodbase)

add_compile_options(-std=c++11)
add_compile_options(-pthread)

file(GLOB_RECURSE files_src src/*.cpp)
file(GLOB_RECURSE files_include include/*.h)

include_directories(
    ${CMAKE_CURRENT_LIST_DIR}/../${PROJECT_NAME}/include    
)

option(USE_ROS "use ros"  ON)
if(USE_ROS)
    find_package(catkin REQUIRED COMPONENTS roscpp class_loader)
    catkin_package(
        INCLUDE_DIRS include
        LIBRARIES jf_aodbase
    )
    include_directories(
        ${catkin_INCLUDE_DIRS}
    )
endif()

add_library(${PROJECT_NAME} SHARED
  ${files_src}
  ${files_include}
)

# 指定动态库版本
# VERSION 动态库版本
# SOVERSION API版本
set_target_properties(${PROJECT_NAME} PROPERTIES VERSION 1.0.1 SOVERSION 1)

# install
if(USE_ROS)
    install(TARGETS ${PROJECT_NAME}
            ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
            LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
            RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
    ## Mark cpp header files for installation
    install(DIRECTORY include/
            DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
            FILES_MATCHING PATTERN "*.h")
    message("${CATKIN_PACKAGE_INCLUDE_DESTINATION}")
else()
    install(TARGETS ${PROJECT_NAME}
            DESTINATION lib)
    install(DIRECTORY include/
            DESTINATION include)
endif()